import 'package:flutter/material.dart';
import 'package:flutter_saixiaoli/pages/activity/activity.dart';
import 'package:flutter_saixiaoli/pages/community/community.dart';
import 'package:flutter_saixiaoli/pages/home/home.dart';
import 'package:flutter_saixiaoli/pages/mine/mine.dart';
import 'package:flutter_saixiaoli/pages/shop/shop.dart';

class Index extends StatefulWidget {
  @override
  State<Index> createState() => _IndexState();
}

class _IndexState extends State<Index> {
  List<Widget> tabbar = [Home(), Activity(), Shop(), Community(), Mine()];
  List<BottomNavigationBarItem> barItemList = [
    BottomNavigationBarItem(
        icon: Image.asset(
          'images/tabbar/1.png',
          width: 20,
          height: 20,
        ),
        activeIcon: Image.asset(
          'images/tabbar/1-1.png',
          width: 20,
          height: 20,
        ),
        label: '首页'),
    BottomNavigationBarItem(
        icon: Image.asset(
          'images/tabbar/2.png',
          width: 20,
          height: 20,
        ),
        activeIcon: Image.asset(
          'images/tabbar/2-2.png',
          width: 20,
          height: 20,
        ),
        label: '活动'),
    BottomNavigationBarItem(
        icon: Image.asset(
          'images/tabbar/3.png',
          width: 20,
          height: 20,
        ),
        activeIcon: Image.asset(
          'images/tabbar/3-3.png',
          width: 20,
          height: 20,
        ),
        label: '商城'),
    BottomNavigationBarItem(
        icon: Image.asset(
          'images/tabbar/4.png',
          width: 20,
          height: 20,
        ),
        activeIcon: Image.asset(
          'images/tabbar/4-4.png',
          width: 20,
          height: 20,
        ),
        label: '社区'),
    BottomNavigationBarItem(
        icon: Image.asset(
          'images/tabbar/5.png',
          width: 20,
          height: 20,
        ),
        activeIcon: Image.asset(
          'images/tabbar/5-5.png',
          width: 20,
          height: 20,
        ),
        label: '我的'),
  ];
  int _currentIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(
      //   title: Text('多威商城'),
      //   elevation: 0,
      //   centerTitle: true,
      // ),
      body: tabbar[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        items: barItemList,
        type: BottomNavigationBarType.fixed,
        unselectedItemColor: Colors.grey,
        selectedItemColor: Color.fromRGBO(191, 55, 54, 1),
        currentIndex: this._currentIndex,
        onTap: (int index) {
          setState(() {
            this._currentIndex = index;
          });
        },
      ),
    );
  }
}
